﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace My_TV_Manager.Model
{
    public static class Conversion
    {
        private static List<KeyValuePair<string, string>> exceptions = new List<KeyValuePair<string, string>>();

        // Add name exception in order to handle series with different names
        public static void AddException(string key, string value)
        {
            exceptions.Add(new KeyValuePair<string, string>(key, value));
        }

        // Remove name exception in order to handle series with different names
        public static void RemoveException(string key, string value)
        {
            foreach (KeyValuePair<string, string> exception in exceptions)
            {
                if (exception.Key == key)
                {
                    exceptions.Remove(exception);
                }
            }
        }

        // Convert the local series name to the TVDB series name
        public static string SeriesLocalToTVDB(string localName)
        {
            foreach (KeyValuePair<string, string> exception in exceptions)
            {
                if (exception.Key == localName)
                {
                    return exception.Value;
                }
            }

            return localName;
        }

        // Convert the TVDB series name to the local series name
        public static string SeriesTVDBToLocal(string TVDBName)
        {
            foreach (KeyValuePair<string, string> exception in exceptions)
            {
                if (exception.Value == TVDBName)
                {
                    return exception.Key;
                }
            }

            return TVDBName;
        }
    }
}
